import { Injectable } from '@nestjs/common';
import { VisiteModel } from 'src/Scheam/visite.scheam';

@Injectable()
export class VisitService {


  async visitweb(year, month, week) {
    return await VisiteModel.create({ year, month, week, review: 1 });
  }
  async register(year, month, week) {
    return await VisiteModel.create({ year, month, week, usercount: 1 });
  }
  async findevist(year, month, week) {
    return await VisiteModel.findOneAndUpdate({ year, month, week }, {
      $inc: { review: 1 }
    });
  }

  async registerfind(year, month, week) {
    return await VisiteModel.findOneAndUpdate({ year, month, week }, {
      $inc: { usercount: 1 }
    });
  }
  async finddata(year, month) {
    return await VisiteModel.find({
      year, month
    }).select('review week usercount')
  }
}
